package com.bckj.freshnow.goods.mapper;

import com.bckj.freshnow.goods.entity.Goods;
import com.bckj.freshnow.goods.model.GoodsResponse;
import com.bckj.freshnow.goods.model.GoodsRequest;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.jdbc.SQL;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;

/**
 * 商品基础表(Goods)表数据库访问层
 *
 * @author makejava
 * @since 2025-04-21 20:09:47
 */
@Mapper
public interface GoodsMapper extends BaseMapper<Goods> {

    /**
      * 列表
      *
      * @param request req
      * @return list
      */
    @SelectProvider(method = "findAll" , type = GoodsProvider.class)
    List<GoodsResponse> findAll(GoodsRequest request);
    
    class GoodsProvider{
        
        public String findAll(GoodsRequest request){
            SQL sql = new SQL();
            sql.SELECT("id, category_id, goods_name, goods_code, goods_desc, cover_image, price, original_price, sales, stock, calories, is_recommend, status, sort, create_time, update_time");
            sql.FROM("goods");
            return sql.toString();
        }
    }
}

